package com.example.transactionTest.controller;

import com.example.transactionTest.bean.User;
import com.example.transactionTest.dao.UserRepository;
//import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
//import org.springframework.web.servlet.ModelAndView;

@RestController
public class UserController {

    private final UserRepository userRepository;

//    @Autowired
    public UserController(UserRepository userRepository) {
        this.userRepository = userRepository;
    }

    @RequestMapping("/user/{id}")
    public User getUser(@PathVariable("id") Long id){
       return userRepository.getOne(id);
//       modelAndView.setView("index");
    }


}
